import Vue from 'vue';
import Router from 'vue-router';


Vue.use(Router);



// 合并所有路由地址
const context = require.context('./children', false, /\.js$/);
let subRoutes = [];
context.keys().forEach(file => {
  subRoutes = subRoutes.concat(context(file).default);
});

let router;
export default function createRouter() {
  router = new Router({
    mode: 'history',
    base: '/',
    routes: subRoutes,
    scrollBehavior() {
      // 路由切换时，页面置顶
      return { x: 0, y: 0 };
    }
  });

  return router;
}
